new Vue({
	el: "#box",
	data: {
		userid: "",
		username: "",
		passwd: "",
		age: 0,
		addr: "",
		company: "",
		tel: "",
		email: "",
		gender: 1
	},
	mounted: function() {
		var that = this;
		this.$http.post("http://127.0.0.1:8080/homework/user/queryById", {
			username: "11",
			userid: "1008"
		}, {
			emulateJSON: true
		}).then(function(res) {
			console.log("res: ", res.body);
			var data = res.body.data[0];
			var sex = 0;
			if (data.gender == "男") {
				sex = 1;
			} else {
				sex = 0;
			}
			that.userid = data.userid;
			that.username = data.username;
			that.passwd = data.passwd;
			that.age = data.age;
			that.gender = sex;
			that.email = data.email;
			that.company = data.company;
			that.addr = data.addr;
		}, function(error) {
			console.log("error: ", error);
		});
	},
	methods: {
		edit: function() {
			var that = this;
			this.$http.post("http://127.0.0.1:8080/homework/user/update", {
				username: that.username,
				userid: that.userid,
				passwd: that.passwd,
				addr: that.addr,
				gender: that.gender,
				company: that.company,
				age: that.age,
				email: that.email
			}, {
				emulateJSON: true
			}).then(function(res) {
				console.log("res: ", res.body.msg);
				alert(res.body.msg);
			}, function(error) {
				console.log("error: ", error);
			})
		},
		cancel: function() {}
	}
});